package person.drf.shop.product.jucTest;

import java.util.concurrent.CountDownLatch;

public class CountDownLatchDemo {
    public static void main(String[] args) throws InterruptedException {

        CountDownLatch countDownLatch = new CountDownLatch(6);

        for (int i = 0; i < 6; i++) {
            new Thread(()->{
                System.out.println(Thread.currentThread().getName()+"学生--离开教室");
                countDownLatch.countDown();
            },String.valueOf(i)).start();
        }
        countDownLatch.await();
        System.out.println(Thread.currentThread().getName());
    }

    private static void closeDemo() {
        for (int i = 0; i < 6; i++) {
             new Thread(()->{
                 System.out.println(Thread.currentThread().getName()+"学生--离开教室");
             },String.valueOf(i)).start();
        }

        System.out.println(Thread.currentThread().getName());
    }
}
